import request from "@/utils/request"

const url = '/pBuy'

// 获取今日采购数据
export function getRecentPurchaseAPI() {
    return request({
        url: `${url}/recent`
    })
}

// 获取采购分页数据
export function getPurchasePageAPI({ page = 1, pageSize = 10, name = '' }) {
    return request({
        url: `${url}/page`,
        params: {
            page,
            pageSize,
            name
        }
    })
}

// 获取采购信息详情
export function getPurchaseDatailAPI(id) {
    return request({
        url: `${url}/${id}`
    })
}

// 获取当前用户的采购信息
export function getOwnPurchaseAPI() {
    return request({
        url: `${url}/persons`
    })
}

// 删除采购信息
export function delPurchaseAPI(id) {
    return request({
        url: `${url}`,
        method: 'DELETE',
        params: {
            id
        }
    })
}

// 发布采购信息
export function addPurchaseAPI({ name, amount, unit, comment, origin, address }) {
    return request({
        url: `${url}`,
        method: 'POST',
        data: {
            name,
            amount,
            unit,
            comment,
            origin,
            address
        }
    })
}